<%--
 * list.jsp
 *
 * Copyright (C) 2013 Universidad de Sevilla
 * 
 * The use of this project is hereby constrained to the conditions of the 
 * TDG Licence, a copy of which you may download from 
 * http://www.tdg-seville.info/License.html
 --%>

<%@page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>

<%@taglib prefix="jstl"	uri="http://java.sun.com/jsp/jstl/core"%>
<%@taglib prefix="spring" uri="http://www.springframework.org/tags"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@taglib prefix="security" uri="http://www.springframework.org/security/tags"%>
<%@taglib prefix="display" uri="http://displaytag.sf.net"%>
<%@taglib prefix="acme" tagdir="/WEB-INF/tags" %>



<fieldset>
<legend>  <spring:message code="comment.painting"/></legend>
<table>

	<tr>
			<td><strong><spring:message code="comment.painting.title" />:</strong></td>
			<td>${comment.painting.title}</td>
	</tr>
	<tr>
			<td><strong><spring:message code="comment.painting.author"/>:</strong></td>
			<td>${comment.painting.author}</td>
	</tr>
	<tr>
			<td><strong><spring:message code="comment.painting.date"/>:</strong></td>
			<td>${comment.painting.date}</td>
	</tr>
</table>			
</fieldset>



<jstl:if test="${comment.parent != null }">

<h3><spring:message code="comment.parent"/></h3>
<fieldset>
<spring:message code="comment.goParent" var="goParent"/>
			<legend>(${comment.parent.moment}) ${comment.parent.customer.nombreCompleto}:</legend>
			${comment.parent.text }
			
			<input type="button" name="goParent" value="${goParent}"
			onclick="javascript: window.location.replace('comment/customer/goParent.do?commentId=${comment.parent.id}')" />
			
</fieldset>
</jstl:if>
<display:table pagesize="5" class="displaytag" 
name="comments" requestURI="/comment/list.do" id="row">

	<spring:message code="comment.comments" var="comments" />
	<spring:message code="comment.reply" var="reply" />
	<display:column  title="${comments}" sortable="true" >	
		<fieldset>
			<legend>(${row.moment}) ${row.customer.nombreCompleto}:</legend>
			${row.text }
			
			<input type="button" name="reply" value="${reply}"
			onclick="javascript: window.location.replace('comment/customer/reply.do?commentId=${row.id}')" />
		
		</fieldset>
	</display:column>
	
	
</display:table>
<security:authorize access="hasRole('CUSTOMER')">

<h3><spring:message code="comment.add"/></h3>
<form:form id="form" name="form" action="comment/customer/edit.do"
	modelAttribute="comment">
	<form:hidden path="id"/>
	<form:hidden path="customer"/>
	<form:hidden path="painting"/>
	<form:hidden path="parent"/>
	<form:hidden path="children"/>
	<form:hidden path="moment"/>
		<fieldset>
			<legend>${comment.customer.nombreCompleto}:</legend>
			<acme:textarea path="text" code="comment.text"  readonly="${readonly}"/>	

		</fieldset>
	
	
	<jstl:if test="${readonly != \"readonly\"}">
		<spring:message code="comment.confirm.save" var="saveMessage" />
		<acme:submit name="save" code="comment.save" onclick="return confirm('${saveMessage}')" />&nbsp; 
	</jstl:if>
	
	<br/>
	
</form:form>
</security:authorize>